package br.ufpe.cin.mac.parser;

import java.util.LinkedList;
import java.util.List;

public class CanonicalElements {

	public static final String TAG_NAME = "CanonicalElements";
	
	private List<XComponent> components;

	private List<XConnector> connectors;

	private XConnector concreteConnector;
	
	public XConnector getConcreteConnector() {
		return concreteConnector;
	}

	public void addConcreteConnector(XConnector concreteConnector) {
		this.concreteConnector = concreteConnector;
	}

	public CanonicalElements() {
		components = new LinkedList<XComponent>();
		connectors = new LinkedList<XConnector>();
	}

	public void addXComponent(XComponent comp) {
		components.add(comp);
	}

	public void addXConnector(XConnector conn) {
		connectors.add(conn);
	}
	
	
	public List<XConnector> getXConnectors(){
		return connectors;
	}
	
	public List<XComponent> getXComponents(){
		return components;
	}

	public XConnector getXConnector(String id){
		for(XConnector conn : this.connectors){
			if(conn.getId().equals(id))
				return conn;
		}
		return null;
	}
	
	public XComponent getXComponent(String id){
		for(XComponent comp : this.components){
			if(comp.getId().equals(id))
				return comp;
		}
		return null;
	}
}
